<template>
  <div class="">
    <ele-pro-table style="width: 100%" :datasource="datasource" :pagination="false" :columns="columns" :toolbar="false">
      <template #type="{ row }">
        <el-tag size="small" :type="getType(row.type)">
          {{ row.type_name }}
        </el-tag>
      </template>
    </ele-pro-table>
  </div>
</template>

<script setup>
const props = defineProps({
  orderId: Number,
})

const { getType } = utils

/** 表格列配置 */
const columns = ref([
  {
    type: 'index',
    label: '序',
    width: 50,
    align: 'left',
    fixed: 'left',
  },
  {
    prop: 'order_sn',
    label: '入库通知单',
    minWidth: 160,
    align: 'left',
    slot: 'order_sn',
  },
  {
    prop: 'type',
    label: '入库类型',
    align: 'center',
    slot: 'type',
  },
  {
    prop: 'supplier_name',
    label: '货主',
    minWidth: 120,
    align: 'center',
  },
  {
    prop: 'warehouse_name',
    label: '收货仓库',
    minWidth: 120,
    align: 'center',
  },
  {
    prop: 'status_name',
    slot: 'status',
    label: '订单状态',
    align: 'center',
    minWidth: 100,
  },
  {
    prop: 'notice_num',
    label: '通知收货数量',
    align: 'center',
    minWidth: 100,
  },
  {
    prop: 'review_num',
    label: '待验收数量',
    align: 'center',
    minWidth: 100,
  },
  {
    prop: 'enter_num',
    label: '入库数量',
    align: 'center',
    minWidth: 100,
  },
  {
    prop: 'remark',
    showOverflowTooltip: true,
    label: '备注',
    align: 'center',
    minWidth: 100,
  },
  {
    prop: 'create_time',
    label: '创建时间',
    formatter: (row) => {
      return utils.formatDate(row.create_time)
    },
    align: 'center',
    width: 160,
    showOverflowTooltip: false,
  },
])

/** 表格数据源 */
function datasource({ page, limit, where, orders }) {
  return utils.get('/purchaseMain/order', { ...where, ...orders, id: props.orderId, is_enter: 0, page, limit })
}
</script>

<style lang="scss" scoped></style>
